package itea.bignews.dwr;

import itea.bignews.News;
import itea.bignews.biz.NewsBiz;

/**
 * 
 * @version $Id: NewsAdminDwr.java 52 2009-09-11 09:32:44Z iteahere $
 * @author itea
 * @date 2009-8-6
 */
public class NewsAdminDwr extends Dwr {

	private NewsBiz newsBiz;
	
	public SResult listAuditingNews() {
		return new SResult(newsBiz.listAuditingNews());
	}
	
	public SResult listActiveNews() {
		return new SResult(newsBiz.listActiveNews());
	}
	
	public SResult listScheduledNews() {
		return new SResult(newsBiz.listSchduledNews());
	}
	
	public SResult publishPosted(Long id) {
		News n = newsBiz.pulishPosted(id);
		return n == null ? SResult.FAILED() : SResult.SUCCEED();
	}

	public SResult schedulePosted(Long newsId) {
		News n = newsBiz.schedulePosted(newsId);
		return n == null ? SResult.FAILED() : SResult.SUCCEED();
	}
	
	public SResult editAndPublishPosted(News n) {
		newsBiz.updatePostedContents(n);
		return this.publishPosted(n.getId());
	}
	public SResult editAndSchedulePosted(News n) {
		newsBiz.updatePostedContents(n);
		return this.schedulePosted(n.getId());
	}
	
	public SResult publishNews(News n) {
		newsBiz.publish(n);
		return SResult.SUCCEED();
	}
	
	public SResult scheduleNews(News n) {
		newsBiz.schedule(n);
		return SResult.SUCCEED();
	}
	
	public SResult removePosted(Long id) {
		News n = newsBiz.removePosted(id);
		return n == null ? SResult.FAILED() : SResult.SUCCEED();
	}
	
	public void setNewsBiz(NewsBiz newsBiz) {
		this.newsBiz = newsBiz;
	}

}
